package hk.ust.android_competition.data_reload_tools;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import hk.ust.android_competition.e_pet.R;

/**
 * Created by Silver on 18/1/15.
 */
public class CostumeListViewAdapter extends ArrayAdapter<String> {
    private Context context;
    private int images[];
    private String text[];
    private Boolean[] notShowLock;

    public CostumeListViewAdapter(Context c, String[] foodStrings, int[] images, Boolean[] notShowLock) {
        super(c, R.layout.costume_list_element, R.id.tv_content_costume_list_view, foodStrings);
        this.context = c;
        this.text = foodStrings;
        this.images = images;
        this.notShowLock = notShowLock;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row = inflater.inflate(R.layout.costume_list_element, parent, false);

        ImageView img = (ImageView) row.findViewById(R.id.iv_costume_list_view_element_icon);
        TextView storeItem = (TextView) row.findViewById(R.id.tv_content_costume_list_view);
        ImageView lock = (ImageView) row.findViewById(R.id.lock);

        img.setImageResource(images[position]);
        storeItem.setText(text[position]);
        if (notShowLock[position]) {
            lock.setVisibility(View.GONE);
        } else {
            lock.setVisibility(View.VISIBLE);
        }
        return row;
    }
}

